package unit3.part4;

public class WhileTest {
    public static void main(String[] args) {
        // while语句
        int sum = 0, i = 1;
        while (i <= 100) {
            sum += i++;
        }
        System.out.println(sum);
        System.out.println("====================");

        // do while语句
        sum = 0;
        i = 1;
        do {
            sum += i++;
        } while (i <= 100);
        System.out.println(sum);
        System.out.println("====================");

        // for
        sum = 0;
        for (int j = 0; j <= 100; j++) {
            sum += j;
        }
        System.out.println(sum);
        System.out.println("====================");
        // for 两个变量
        for (int n = 1, m = 1; n <= 5; n++, m = m + n * 2) {
            System.out.print(m + " ");
        }
        System.out.println();
        System.out.println("====================");
//        for (int j = 0; ; j++) {
//
//        }

        // 3.4.4.嵌套循环
        for (int n = 1; n <= 9; n++) {
            for (int m = 1; m <= n; m++) {
                System.out.print(n + "*" + m + "=" + n * m + "\t");
            }
            System.out.println();
        }
    }
}
